{include file="header_ajax.tpl" title=$title}

<h2>{$title}</h2>

<!--
<div class="box">
<h4>Offers</h4>
Data <strong>{$dataO->CNT}</strong> entries ranges from <strong>{$dataO->MINDATE}</strong> to <strong>{$dataO->MAXDATE}</strong><br>
Total Sum: <strong>{$dataO->SUMM}</strong> Bucks
<h4>Invoices</h4>
Data <strong>{$dataI->CNT}</strong> entries ranges from <strong>{$dataI->MINDATE}</strong> to <strong>{$dataI->MAXDATE}</strong><br>
Total Sum: <strong>{$dataI->SUMM}</strong> Bucks
</div>
-->

<div class="box">
<form method="post" action="report.php">
<table class="righter">
<tr><td>From Date</td><td><input type="text" name="from" value="{$from}"></td>
<td>To Date</td><td><input type="text" name="to" value="{$to}"></td>
<td>Type</td><td><select name="type"><option value="%">Both</option><option value="O">Quotations</option><option value="I">Invoices</option></select></tr>
<tr><td>Customer</td><td><select name="customer[]" multiple size="5"><option value="%" selected>All</option>{foreach from=$customers key=k item=v}<option value="{$v->ID}">{$v->FAMILYNAME}, {$v->FIRSTNAME} ({$v->CITY})</option>{/foreach}</select>
<td>Work Items</td><td><select name="works[]" multiple size="5"><option value="%" selected>All</option>{foreach from=$workItems key=k item=v}<option value="{$v->ID}">{$v->WORK_TEXT}</option>{/foreach}</select>
<td colspan="2"><input type="submit" value="generate report"></td></tr>
</table>
</form>
</div>

<div class="box">
<table class="results">
<tr>
<th>Type</th>
<th>Customer</th>
<th>Location</th>
<th>Amount</th>
<th>Price per</th>
<th>Work Item</th>
<th>Discount</th>
<th>Total</th>
<th>Date</th>
</tr>
{foreach from=$rData key=k item=v}
<tr><!-- td>{$v->AOID}</td -->
<td>
{if $v->ITEM_TYP eq 'O'}Offer{/if}
{if $v->ITEM_TYP eq 'I'}Invoice{/if}
</td>
<td>{$v->TITLE} {$v->FAMILYNAME}, {$v->FIRSTNAME}</td>
<td>{$v->CITY}, {$v->ZIP}</td>
<td>{$v->DAMOUNT} {$v->MEASURE_UNIT}</td>
<td>{$v->DUNIT_PRICE}</td>
<td>{$v->WORK_TEXT}</td>
<td>{$v->DISCOUNT}</td>
<td>
{math equation="x * y * z" x=$v->DISCOUNT y=$v->DAMOUNT z=$v->DUNIT_PRICE}
</td>
<!-- td>{$v->TOTAL}</td -->
<td>{$v->DATE}</td>
</tr>
{/foreach}
</table>
SUM: <strong>{$totalSum->SUMM}</strong> bucks in <strong>{$totalSum->CNT}</strong> entries</strong>
</div>

{include file="footer.tpl"}
